Skip to content

chore(mypy): fix type hints for inline provider files#5399

Open
Elbehery wants to merge 2 commits intollamastack:mainfrom
Elbehery:20260401_add_type_hints_cli_module
Open

chore(mypy): fix type hints for inline provider files#5399
Elbehery wants to merge 2 commits intollamastack:mainfrom
Elbehery:20260401_add_type_hints_cli_module

Conversation

@Elbehery
Copy link
Copy Markdown
Contributor

@Elbehery Elbehery commented Apr 1, 2026

What does this PR do?

Fix mypy strict type checking errors in inline provider files:

  1. Fixed SentenceTransformerEmbeddingMixin.model_store type to match InferenceProvider protocol (ModelStore | None instead of ModelStore)

  2. Fixed eval.py type errors:

    • Added type annotations for jobs and benchmarks dicts
    • Fixed variable shadowing in benchmark iteration
    • Added proper type annotations for sampling_params (dict[str, Any])
    • Fixed message type handling with proper union types
    • Separated completion and chat_completion variable scopes
    • Added assertions for non-streaming responses
    • Added assertion for non-None content in chat responses

cc @leseb

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 1, 2026
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch 2 times, most recently from 7a3ad27 to 1281090 Compare April 1, 2026 13:35
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch 8 times, most recently from ed6fa50 to 3d6839b Compare April 2, 2026 09:29
Copy link
Copy Markdown
Collaborator

@leseb leseb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not rename variables like chat_params unless it's fixing something, the PR description does not mention it, thanks!

@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch from 3d6839b to 0d80df5 Compare April 2, 2026 15:33
@Elbehery
Copy link
Copy Markdown
Contributor Author

Elbehery commented Apr 2, 2026

please do not rename variables like chat_params unless it's fixing something, the PR description does not mention it, thanks!

ptal

Elbehery added 2 commits April 2, 2026 17:39
  Fix mypy strict type checking errors in inline provider files:

  - Add type annotations for jobs/benchmarks dictionaries
  - Fix variable shadowing (benchmark → benchmark_json)
  - Add sampling_params type annotation (dict[str, Any])
  - Separate completion and chat variable scopes
  - Add proper union types for messages list
  - Add assertions for non-streaming responses and non-None content
  - Add config attribute declaration (Any type)
  - Change model_store from ModelStore to ModelStore | None
  - Import OpenAIChatCompletionWithReasoning types
  - Add correct return type for openai_chat_completions_with_reasoning
  - Import OpenAIChatCompletionWithReasoning types
  - Add correct return type for openai_chat_completions_with_reasoning

  pyproject.toml:
  - Add sentence_transformers to mypy ignore_missing_imports (no type stubs)

  Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
Revert chat_params/completion_params back to params and chat_response/completion_response back to response. These renames were not fixing anything and added noise to the diff.

Keep all the actual type hints and assertions that add value.

Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery Elbehery force-pushed the 20260401_add_type_hints_cli_module branch from 0d80df5 to 6fca531 Compare April 2, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants